<?php
class Customer_Form_BookingFinish extends TBB_Form
{
	public function init()
	{		
		$this->addAttribs(array(
			'class' => 'span-8',
			'id' => 'bookingFinishForm'			
		));
		
		// create captcha
		$captcha = $this->_createCaptcha();		
		
		// create login button
		$submit = $this->_createSubmitButton();
		
		$this->addElements(array($captcha, $submit));
		$this->addDisplayGroup(array('captcha', 'submit'), 'bookingFinishGroup');
		        
		$this->setDecorators($this->_formDecorators);
		$this->setDisplayGroupDecorators($this->_displayGroupDecorators);
		
		// override fieldset class
		$this->getDisplayGroup('bookingFinishGroup')->setAttrib('class', 'fieldsetForm span-7');
		$this->getDisplayGroup('bookingFinishGroup')->setAttrib('style', 'margin-left: 22em;');
	}
	
	private function _createCaptcha()
	{		
		$captchaAdapter = new Zend_Captcha_Image();
		$captchaAdapter->setFont('./fonts/times.ttf')
					   ->setWordlen(5)
					   ->setLineNoiseLevel(4)
					   ->setDotNoiseLevel(20)
					   ->setMessage('Làm ơn nhập mã xác nhận.', 'badCaptcha');
					   		   
		$captcha = new Zend_Form_Element_Captcha('captcha', array(
		    'captcha' => $captchaAdapter
		));
		$captcha->setLabel('Mã xác nhận: ')
				->setRequired(true);
		$captcha = $this->_customizeFormElement($captcha);
		return $captcha;
	}
	
	private function _createSubmitButton()
	{
		$submit = $this->createElement('submit', 'submit')
					   ->setLabel('Hoàn tất đặt vé')
					   ->setDecorators($this->_submitDecorators)					   
					   ->setAttribs(array(
							'class' => 'span-4 submitDecorator',
					   		'id' => 'submitOnBookingFinish'
						));
		return $submit;
	}
}